<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('项目管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>状态：</label>
                            <select name="status">
                                <option value="">全部</option>
                                <option value="报告待审核">报告待审核</option>
                                <option value="审核不通过">审核不通过</option>
                                <option value="审核通过">审核通过</option>
                                <option value="已上传">已上传</option>
                            </select>
                        </li>
                        <li>
                            <label>项目名称：</label>
                            <input name="projectName" type="text"/>
                        </li>
                        <li>
                            <label>项目编号：</label>
                            <input name="projectCode" type="text"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:management:add">
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<!-- 新增的功能点列表模态框 -->
<div aria-hidden="true" aria-labelledby="featureListModalLabel" class="modal fade" id="featureListModal" role="dialog"
     tabindex="-1">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="featureListModalLabel">功能点列表</h5>
                <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>子系统</th>
                        <th>模块</th>
                        <th>调整前功能点数</th>
                        <th>调整后工作量（人日）</th>
                        <th>开发费用</th>
                        <th>费用占比</th>
                    </tr>
                    </thead>
                    <tbody id="featureListBody">
                    <!-- 动态插入数据 -->
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" data-dismiss="modal" type="button">关闭</button>
            </div>
        </div>
    </div>
</div>

<!-- 模态框 -->
<div aria-hidden="true" aria-labelledby="generateReportModalLabel" class="modal fade" id="generateReportModal"
     role="dialog"
     tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="generateReportModalLabel">生成报告</h5>
                <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label for="elementSelect">选择元素：</label>
                    <select class="form-control" id="elementSelect">
                        <option value="科技">科技</option>
                        <option value="商务">商务</option>
                        <option value="教育">教育</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="styleSelect">选择风格：</label>
                    <select class="form-control" id="styleSelect">
                        <option value="现代">现代</option>
                        <option value="简约">简约</option>
                        <option value="复古">复古</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="templateSelect">选择模板：</label>
                    <select class="form-control" id="templateSelect">
                        <option value="科技模板">科技模板</option>
                        <option value="商务模板">商务模板</option>
                        <option value="教育模板">教育模板</option>
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" data-dismiss="modal" type="button">取消</button>
                <button class="btn btn-primary" onclick="generateReport()" type="button">确定</button>
            </div>
        </div>
    </div>
</div>


<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:management:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:management:remove')}]];
    var prefix = ctx + "system/management";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "项目管理",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'status',
                    title: '状态'
                },
                {
                    field: 'projectCode',
                    title: '项目编号'
                },
                {
                    field: 'expectedDuration',
                    title: '预期工期'
                },
                {
                    field: 'estimatedCost',
                    title: '评估金额'
                },
                {
                    field: 'createdTime',
                    title: '创建时间'
                },
                {
                    field: 'updatedTime',
                    title: '更新时间'
                },
                {
                    field: 'bat1',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="showDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i>详情</a>');
                        //根据状态显示 已上传显示生成报告
                        if (row.status === '已上传') {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="showGenerateReportModal(\'' + row.id + '\')"><i class="fa fa-file-text"></i>生成报告</a>');
                        }
                        if (row.status === '报告待审核') {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="viewReport(\'' + row.id + '\')"><i class="fa fa-file-text"></i>查看报告</a>');
                        }
                        if (row.status === '审核不通过') {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');

                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function showFeatureListModal(id) {
        // 假数据
        var featureList = [
            {
                id: 1,
                subsystem: '子系统1',
                module: '模块1',
                beforeFP: 10,
                afterWorkload: 20,
                cost: 1000,
                costRatio: '10%'
            },
            {
                id: 2,
                subsystem: '子系统2',
                module: '模块2',
                beforeFP: 15,
                afterWorkload: 25,
                cost: 1500,
                costRatio: '15%'
            },
            {
                id: 3,
                subsystem: '子系统3',
                module: '模块3',
                beforeFP: 20,
                afterWorkload: 30,
                cost: 2000,
                costRatio: '20%'
            },
            {
                id: 4,
                subsystem: '子系统4',
                module: '模块4',
                beforeFP: 25,
                afterWorkload: 35,
                cost: 2500,
                costRatio: '25%'
            },
            {
                id: 5,
                subsystem: '子系统5',
                module: '模块5',
                beforeFP: 30,
                afterWorkload: 40,
                cost: 3000,
                costRatio: '30%'
            },
            {
                id: 6,
                subsystem: '子系统6',
                module: '模块6',
                beforeFP: 35,
                afterWorkload: 45,
                cost: 3500,
                costRatio: '35%'
            },
            {
                id: 7,
                subsystem: '子系统7',
                module: '模块7',
                beforeFP: 40,
                afterWorkload: 50,
                cost: 4000,
                costRatio: '40%'
            },
            {
                id: 8,
                subsystem: '子系统8',
                module: '模块8',
                beforeFP: 45,
                afterWorkload: 55,
                cost: 4500,
                costRatio: '45%'
            },
            {
                id: 9,
                subsystem: '子系统9',
                module: '模块9',
                beforeFP: 50,
                afterWorkload: 60,
                cost: 5000,
                costRatio: '50%'
            },
            {
                id: 10,
                subsystem: '子系统10',
                module: '模块10',
                beforeFP: 55,
                afterWorkload: 65,
                cost: 5500,
                costRatio: '55%'
            },
            {
                id: 11,
                subsystem: '子系统11',
                module: '模块11',
                beforeFP: 60,
                afterWorkload: 70,
                cost: 6000,
                costRatio: '60%'
            },
            {
                id: 12,
                subsystem: '子系统12',
                module: '模块12',
                beforeFP: 65,
                afterWorkload: 75,
                cost: 6500,
                costRatio: '65%'
            },
            {
                id: 13,
                subsystem: '子系统13',
                module: '模块13',
                beforeFP: 70,
                afterWorkload: 80,
                cost: 7000,
                costRatio: '70%'
            },
            {
                id: 14,
                subsystem: '子系统14',
                module: '模块14',
                beforeFP: 75,
                afterWorkload: 85,
                cost: 7500,
                costRatio: '75%'
            },
            {
                id: 15,
                subsystem: '子系统15',
                module: '模块15',
                beforeFP: 80,
                afterWorkload: 90,
                cost: 8000,
                costRatio: '80%'
            }
        ];

        // 清空表格内容
        $('#featureListBody').empty();

        // 插入数据
        featureList.forEach(function (feature) {
            var row = '<tr>' +
                '<td>' + feature.id + '</td>' +
                '<td>' + feature.subsystem + '</td>' +
                '<td>' + feature.module + '</td>' +
                '<td>' + feature.beforeFP + '</td>' +
                '<td>' + feature.afterWorkload + '</td>' +
                '<td>' + feature.cost + '</td>' +
                '<td>' + feature.costRatio + '</td>' +
                '</tr>';
            $('#featureListBody').append(row);
        });

        // 显示模态框
        $('#featureListModal').modal('show');
    }

    // 修改详情按钮的点击事件
    function showDetail(id) {
        showFeatureListModal(id);
    }

    function showGenerateReportModal(id) {
        $('#generateReportModal').data('row-id', id).modal('show');
    }

    function generateReport() {
        //发送请求
        var rowId = $('#generateReportModal').data('row-id');
        var element = $('#elementSelect').val();
        var style = $('#styleSelect').val();
        var template = $('#templateSelect').val();

        // 发送请求，将数据发送到后端进行处理
        $.ajax({
            url: prefix + '/edit',
            type: 'POST',
            data: {
                id: rowId,
                status: '报告待审核'
            },
            success: function (response) {
                //关闭弹窗
                $('#generateReportModal').modal('hide');
                $.modal.msgSuccess('生成报告成功');
                $.table.search()
            }
        })
    }

    function viewReport(id) {
        //下载本地的word 三个随机下一个
        var fileId = id % 3; // 假设 id 是 1, 2, 3, 4, 5, 6, ...
        window.location.href = ctx + 'doc/示例项目' + (fileId === 0 ? 3 : fileId) + '.docx';

    }
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('项目管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>状态：</label>
                            <select name="status">
                                <option value="">全部</option>
                                <option value="报告待审核">报告待审核</option>
                                <option value="审核不通过">审核不通过</option>
                                <option value="审核通过">审核通过</option>
                                <option value="已上传">已上传</option>
                            </select>
                        </li>
                        <li>
                            <label>项目名称：</label>
                            <input name="projectName" type="text"/>
                        </li>
                        <li>
                            <label>项目编号：</label>
                            <input name="projectCode" type="text"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:management:add">
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<!-- 新增的功能点列表模态框 -->
<div aria-hidden="true" aria-labelledby="featureListModalLabel" class="modal fade" id="featureListModal" role="dialog"
     tabindex="-1">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="featureListModalLabel">功能点列表</h5>
                <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>子系统</th>
                        <th>模块</th>
                        <th>调整前功能点数</th>
                        <th>调整后工作量（人日）</th>
                        <th>开发费用</th>
                        <th>费用占比</th>
                    </tr>
                    </thead>
                    <tbody id="featureListBody">
                    <!-- 动态插入数据 -->
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" data-dismiss="modal" type="button">关闭</button>
            </div>
        </div>
    </div>
</div>

<!-- 模态框 -->
<div aria-hidden="true" aria-labelledby="generateReportModalLabel" class="modal fade" id="generateReportModal"
     role="dialog"
     tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="generateReportModalLabel">生成报告</h5>
                <button aria-label="Close" class="close" data-dismiss="modal" type="button">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="form-group">
                    <label for="elementSelect">选择元素：</label>
                    <select class="form-control" id="elementSelect">
                        <option value="element1">元素1</option>
                        <option value="element2">元素2</option>
                        <option value="element3">元素3</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="styleSelect">选择风格：</label>
                    <select class="form-control" id="styleSelect">
                        <option value="style1">风格1</option>
                        <option value="style2">风格2</option>
                        <option value="style3">风格3</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="templateSelect">选择模板：</label>
                    <select class="form-control" id="templateSelect">
                        <option value="template1">模板1</option>
                        <option value="template2">模板2</option>
                        <option value="template3">模板3</option>
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-secondary" data-dismiss="modal" type="button">取消</button>
                <button class="btn btn-primary" onclick="generateReport()" type="button">确定</button>
            </div>
        </div>
    </div>
</div>

<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:management:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:management:remove')}]];
    var prefix = ctx + "system/management";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "项目管理",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'status',
                    title: '状态'
                },
                {
                    field: 'projectCode',
                    title: '项目编号'
                },
                {
                    field: 'expectedDuration',
                    title: '预期工期'
                },
                {
                    field: 'estimatedCost',
                    title: '评估金额'
                },
                {
                    field: 'createdTime',
                    title: '创建时间'
                },
                {
                    field: 'updatedTime',
                    title: '更新时间'
                },
                {
                    field: 'bat1',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="showDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i>详情</a>');
                        //根据状态显示 已上传显示生成报告
                        if (row.status === '已上传') {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="showGenerateReportModal(\'' + row.id + '\')"><i class="fa fa-file-text"></i>生成报告</a>');
                        }
                        if (row.status === '报告待审核') {
                            actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="viewReport(\'' + row.id + '\')"><i class="fa fa-file-text"></i>查看报告</a>');
                        }
                        if (row.status === '审核不通过') {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');

                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function showFeatureListModal(id) {
        // 假数据
        var featureList = [
            {
                id: 1,
                subsystem: '子系统1',
                module: '模块1',
                beforeFP: 10,
                afterWorkload: 20,
                cost: 1000,
                costRatio: '10%'
            },
            {
                id: 2,
                subsystem: '子系统2',
                module: '模块2',
                beforeFP: 15,
                afterWorkload: 25,
                cost: 1500,
                costRatio: '15%'
            },
            {
                id: 3,
                subsystem: '子系统3',
                module: '模块3',
                beforeFP: 20,
                afterWorkload: 30,
                cost: 2000,
                costRatio: '20%'
            },
            {
                id: 4,
                subsystem: '子系统4',
                module: '模块4',
                beforeFP: 25,
                afterWorkload: 35,
                cost: 2500,
                costRatio: '25%'
            },
            {
                id: 5,
                subsystem: '子系统5',
                module: '模块5',
                beforeFP: 30,
                afterWorkload: 40,
                cost: 3000,
                costRatio: '30%'
            },
            {
                id: 6,
                subsystem: '子系统6',
                module: '模块6',
                beforeFP: 35,
                afterWorkload: 45,
                cost: 3500,
                costRatio: '35%'
            },
            {
                id: 7,
                subsystem: '子系统7',
                module: '模块7',
                beforeFP: 40,
                afterWorkload: 50,
                cost: 4000,
                costRatio: '40%'
            },
            {
                id: 8,
                subsystem: '子系统8',
                module: '模块8',
                beforeFP: 45,
                afterWorkload: 55,
                cost: 4500,
                costRatio: '45%'
            },
            {
                id: 9,
                subsystem: '子系统9',
                module: '模块9',
                beforeFP: 50,
                afterWorkload: 60,
                cost: 5000,
                costRatio: '50%'
            },
            {
                id: 10,
                subsystem: '子系统10',
                module: '模块10',
                beforeFP: 55,
                afterWorkload: 65,
                cost: 5500,
                costRatio: '55%'
            },
            {
                id: 11,
                subsystem: '子系统11',
                module: '模块11',
                beforeFP: 60,
                afterWorkload: 70,
                cost: 6000,
                costRatio: '60%'
            },
            {
                id: 12,
                subsystem: '子系统12',
                module: '模块12',
                beforeFP: 65,
                afterWorkload: 75,
                cost: 6500,
                costRatio: '65%'
            },
            {
                id: 13,
                subsystem: '子系统13',
                module: '模块13',
                beforeFP: 70,
                afterWorkload: 80,
                cost: 7000,
                costRatio: '70%'
            },
            {
                id: 14,
                subsystem: '子系统14',
                module: '模块14',
                beforeFP: 75,
                afterWorkload: 85,
                cost: 7500,
                costRatio: '75%'
            },
            {
                id: 15,
                subsystem: '子系统15',
                module: '模块15',
                beforeFP: 80,
                afterWorkload: 90,
                cost: 8000,
                costRatio: '80%'
            }
        ];

        // 清空表格内容
        $('#featureListBody').empty();

        // 插入数据
        featureList.forEach(function (feature) {
            var row = '<tr>' +
                '<td>' + feature.id + '</td>' +
                '<td>' + feature.subsystem + '</td>' +
                '<td>' + feature.module + '</td>' +
                '<td>' + feature.beforeFP + '</td>' +
                '<td>' + feature.afterWorkload + '</td>' +
                '<td>' + feature.cost + '</td>' +
                '<td>' + feature.costRatio + '</td>' +
                '</tr>';
            $('#featureListBody').append(row);
        });

        // 显示模态框
        $('#featureListModal').modal('show');
    }

    // 修改详情按钮的点击事件
    function showDetail(id) {
        showFeatureListModal(id);
    }

    function showGenerateReportModal(id) {
        $('#generateReportModal').data('row-id', id).modal('show');
    }

    function generateReport() {
        //发送请求
        var rowId = $('#generateReportModal').data('row-id');
        var element = $('#elementSelect').val();
        var style = $('#styleSelect').val();
        var template = $('#templateSelect').val();

        // 发送请求，将数据发送到后端进行处理
        $.ajax({
            url: prefix + '/edit',
            type: 'POST',
            data: {
                id: rowId,
                status: '报告待审核'
            },
            success: function (response) {
                //关闭弹窗
                $('#generateReportModal').modal('hide');
                $.modal.msgSuccess('生成报告成功');
                $.table.search()
            }
        })
    }

    function viewReport(id) {
        //下载本地的word 三个随机下一个
        var fileId = id % 3; // 假设 id 是 1, 2, 3, 4, 5, 6, ...
        window.location.href = ctx + 'doc/示例项目' + (fileId === 0 ? 3 : fileId) + '.docx';
    }
</script>
</body>
</html>
